package com.tanhua.dubbo.server.service;

import com.tanhua.dubbo.server.enums.IdType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * * @title: IdService
 *
 * @Author Philcan
 * @Date: 2021/8/11 20:54
 * @Version 1.0
 */
@Service
public class IdService {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    public Long createdId(IdType idType) {
        String idKey = "TANHUA_ID_" + idType.toString();
        return this.redisTemplate.opsForValue().increment(idKey);
    }
}
